package com.gonsin.gview.logic.config;

import io.github.classgraph.utils.VersionFinder;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.io.File;
import java.io.IOException;

@Getter
@Setter
public class GViewFileProperties implements InitializingBean {

    private String tempPath = "";        // 临时文件目录
    public static String TEMP_PATH = "";

    @Override
    public void afterPropertiesSet() throws Exception {
        if(StringUtils.isEmpty(tempPath)){
            switch (VersionFinder.OS){
                case Windows:
                    tempPath = "C:/temp";
                    break;
                default:
                    tempPath = new File("./temp").getAbsolutePath();
            }
        }
        TEMP_PATH = tempPath;
    }
}
